<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>

<head>
    <base href="<%=basePath%>"/>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css" />
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>
</head>
<body>
<div class="container col-sm-12">
    <%-- 标题--%>
    <div class="panel-heading">
        <h2>我的资产移动列表</h2>

        <form class="form-horizontal" action="" method="post" role="form">
        申请日期：<input type="date" name="startDate">
        <input type="date" name="endDate">
        单据状态：<select name="status">
        <option>~请选择状态~</option>
        <option value="0">~待提交~</option>
        <option value="1">~未通过~</option>
        <option value="2">~已通过~</option>
        <option value="3">~待查阅~</option>

    </select>
        <input type="submit" value="搜索">
        </form>
    </div>
    <div class="panel-body">
        <table width="900px">
            <tr>
                <th>申请单号</th>
                <th>审批流程</th>
                <th>创建人</th>
                <th>申请日期</th>
                <th>所属部门</th>
                <th>单据状态</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${list}" var="yd">
                <tr>
                    <td>${yd.docNo}</td>
                    <td>${yd.lcid.flowName}</td>
                    <td>${yd.empcj.empName}</td>
                    <td>${yd.createDate}</td>
                    <td>${yd.dept.deptName}</td>
                    <td>
                        <c:if test="${yd.status=='0'}">
                            待提交
                        </c:if>
                        <c:if test="${yd.status=='1'}">
                            未通过
                        </c:if>
                        <c:if test="${yd.status=='2'}">
                            已通过
                        </c:if>
                        <c:if test="${yd.status=='3'}">
                            待查阅
                        </c:if>
                        <c:if test="${yd.status=='4'}">
                            已办理移动
                        </c:if>
                    </td>
                    <td>
                        <c:if test="${yd.status=='0'}">
                            <a href="zcyd/tijiao?oid=${yd.oid}&status=0">提交</a>/<a href="zcyd/toupdate?oid=${yd.oid}">修改</a>/ <button onclick="deletecard(${yd.oid})" data-toggle="modal" data-target="#confirmModal">删除 </button>
                        </c:if>
                        <c:if test="${yd.status=='1'}">
                            <button onclick="deletecard(${yd.oid})" data-toggle="modal" data-target="#confirmModal">删除 </button>
                        </c:if>
                        <c:if test="${yd.status=='2'}">
                            <a href="zcyd/tobanli?oid=${yd.oid}&status=2">审批通过/去办理</a>/ <button onclick="deletecard(${yd.oid})" data-toggle="modal" data-target="#confirmModal">删除 </button>
                        </c:if>
                        <c:if test="${yd.status=='3'}">
                            <a href="zcyd/toupdate?oid=${yd.oid}">修改</a>/ <button onclick="deletecard(${yd.oid})" data-toggle="modal" data-target="#confirmModal">删除 </button>
                        </c:if>
                        <c:if test="${yd.status=='4'}">
                            <button onclick="deletecard(${yd.oid})" data-toggle="modal" data-target="#confirmModal">删除 </button>
                        </c:if>

                    </td>
                </tr>
            </c:forEach>
            <tr>
                <td colspan="7">
                    <button class="btn btn-primary btn-xs pull-right" data-toggle="modal" data-target="#myModal">
                        新建移动资产
                    </button>
                </td>
            </tr>
        </table>
    </div>

    <!-- 资产移动申请添加页面 -->

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" aria-hidden="true" >
        <form action="zcyd/insert" id="form" class="form-horizontal"
              method="post" role="form">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">&times;
                        </button>
                        <h4 class="modal-title" id="myModalLabel">移动资产申请添加页面</h4>
                    </div>
                    <div class="modal-body" id="infordiv">
                        <div class="col-md-12">
                            <label class="col-sm-2 control-label">申请单号</label>
                            <div class="col-md-4">
                                <font color="red">待生成...</font>
                            </div>


                            <label class="col-sm-2 control-label">创建人</label>
                            <div class="col-md-4">
                                <input type="hidden" class="form-control" name="creator"
                                       value="${sessionScope.empid}" readonly=" readonly">
                                <input type="text" class="form-control" name="creator1"
                                       value="${sessionScope.empname}" readonly=" readonly">
                            </div>
                        </div>
                        <div class="col-md-12">
                            <label class="col-sm-2 control-label">审批流程</label>
                            <div class="col-md-4">

                                <select id="sb" class="form-group" name="flowid">
                                    <option value="">请选择审批流程</option>
                                    <c:forEach items="${lclist }" var="lc">
                                        <option value="${lc.oid }">${lc.flowName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                            <label class="col-md-2">单据类型</label>
                            <div class="col-md-2">
                                <input type="text" class="form-control" name="doctype">
                            </div>
                        </div>
                        <div class="col-md-12">

                            <label class="col-sm-2 control-label">移动原因</label>
                            <div class="col-md-4">
                                <select class="form-group" name="moveReason">
                                    <option value="">请选择移动原因</option>
                                    <c:forEach items="${jcyylist }" var="jcy">
                                        <option value=" ${jcy.oid }">${jcy.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                            <label class="col-sm-3 control-label">移动申请时间</label>
                            <div class="col-md-3">
                                <font color="red">待生成...</font>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <label class="col-sm-2 control-label">选择部门</label>
                            <div class="col-md-4">
                                <select class="form-group" name="deptid" id="deptid">
                                    <option value="">请选择部门</option>
                                    <c:forEach items="${deptlist }" var="d">
                                        <option value=" ${d.oid }">${d.deptName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                            <label class="col-sm-2 control-label">申请人</label>
                            <div class="col-md-4">

                                <select id="semp" class="form-group" name="proposer">
                                    <option value="">请选择申请人</option>
                                    <c:forEach items="${emplist }" var="emp">
                                        <option value=" ${emp.oid }">${emp.empName}</option>
                                    </c:forEach>
                                </select>
                            </div>

                        </div>
                        <div class="col-lg-12">
                            <label class="col-sm-2 control-label">备注</label>
                            <div class="col-md-9">
                                <textarea name="remark"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <button type="button" onclick="Inserttable()"
                                    class="btn btn-primary">添加移动明细
                            </button>
                        </div>


                    </div>
                    <div class="modal-footel">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="submit" class="btn btn-primary">提交申请</button>
                    </div>
                </div>
            </div>
        </form>
    </div>

    <div id="demodiv" class="form-group" style="display: none">
        <div class="col-md-12">
            <label class="col-md-2">选择资产</label>
            <div class="col-md-3">
                <select name="assetId" class="form-group" id="assetId" onchange=" selectAsset(this) ">
                    <option value="">请选择资产</option>
                    <c:forEach items="${zclist }" var="zc">
                        <option value="${zc.oid }">${zc.assetNanme}</option>
                    </c:forEach>
                </select>
            </div>

            <label class="col-md-2">移动地</label>
            <div class="col-md-2">
                <select name="targetPlace" class="form-group">
                    <option value="">请选择地点</option>
                    <c:forEach items="${jclist }" var="jc">
                        <option value="${jc.oid }">${jc.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="col-md-12">
            <label class="col-md-2">备注</label>
            <div class="col-md-9">
                <textarea name="remark"></textarea>
            </div>
            <div class="col-md-2">
                <button type="button" onclick="remove(this)" class="btn btn-primary">删除</button>
            </div>
        </div>

    </div>
        <div id="alertmsg" class="alert alert-danger" style="text-align: center;" hidden="true"></div>
</body>


<%@include file="../modal/confirm.jsp" %>
<script type="text/javascript">
    function Inserttable() {
        var demodiv = $("#demodiv").clone(true);
        demodiv.attr("id", "");
        demodiv.show();
        demodiv.appendTo($("#infordiv"));
    }

    function remove(r) {
        $(r).parent().parent().parent().remove();
    }
   // zcyd/selectjl
    $("#deptid").change(function () {

        $.getJSON("zcyd/selectjl", {deptid: $("#deptid").val()}, function (msg) {
            console.log(msg)
            var emp = $("#semp")[0];
            emp.options.length = 1;
            for (var i = 0; i < msg.length; i++) {
                var emp1 = msg[i];
                emp.options.add(new Option(emp1.empName, emp1.oid));
            }
        });
    });


    var deleteoid;

    function deletecard(oid) {
        deleteoid = oid;
    }

    function deleteConfirm() {
        $.get("zcyd/delete", {"oid": deleteoid}, function (s) {
            if (s == true) {
                document.location.href = "zcyd/select";
            } else {
                $("#alertmsg").text("删除失败!该资产有明细!");
                $("#alertmsg").slideDown();
                $("#alertmsg").delay(2000).slideUp();
            }
        }).complete(function (xhr) {
            if (xhr.status == "403") {//没有权限
                document.location.href = xhr.getResponseHeader("url");
            } else if (xhr.status != "200") {
                console.log("服务器错误!");
            }
        });

    }
    


</script>
</html>
